home *** CD-ROM | disk | FTP | other *** search
-
- /*
-
- This file is a part of the GLASS source distribution
- and therefore subjected to the copy notice below.
-
- Copyright (C) 1989,1990 S.J. Klaver, R Doesborg
- email: simon@sagan.nl
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation version 1
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
- #include <stdio.h>
-
- typedef struct stackel
- { int menuid;
- int itemindex;
- };
-
- #define STACKSIZE 10
-
- static struct stackel stack[STACKSIZE];
- static int stackpointer = 0;
-
- int push_element (id, index)
- int id;
- int index;
- {
- if (stackpointer == STACKSIZE) {
- fprintf(stderr, "Stack overflow ...\n");
- return(1);
- }
- else {
- stackpointer++;
- stack[stackpointer].menuid = id;
- stack[stackpointer].itemindex = index;
- return(0);
- }
- }
-
- int pull_element (id, index)
- int *id;
- int *index;
- {
- if (stackpointer == 0) {
- fprintf(stderr, "Illegal pull: stack empty.\n");
- return(1);
- }
- else {
- *id = stack[stackpointer].menuid;
- *index = stack[stackpointer].itemindex;
- stackpointer--;
- return(0);
- }
- }
-